/*
* berton
*/
package com.pitop.market.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

import com.pitop.market.api.MarketRepairRecordFeignApi;
import com.pitop.core.exceptions.MarketRepairRecordException;
import com.pitop.core.exceptions.BaseException;
import com.pitop.core.entity.Page;
import com.pitop.market.entity.MarketRepairRecord;


/**
 * 维修记录
 * @author berton
 */
@Service("marketRepairRecordSVImpl")
@Slf4j
public class MarketRepairRecordSVImpl {

    @Autowired
    private MarketRepairRecordFeignApi marketRepairRecordFeignApi;

    /**
     * 加载一个对象MarketRepairRecord
     * @param id * @param code 编码
     * @return MarketRepairRecord
     */
    public MarketRepairRecord load(java.lang.Long id,java.lang.String code) {
        if(id==null&&code==null){
            throw new MarketRepairRecordException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        return marketRepairRecordFeignApi.load(id,code);
    }
    /**
     * 加载一个对象MarketRepairRecord 通过id
     * @param id 
     * @return MarketRepairRecord
     */
    public MarketRepairRecord loadById(java.lang.Long id) {
        if(id==null){
            throw new MarketRepairRecordException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        return marketRepairRecordFeignApi.loadById(id);
    }

    /**
     * 加载一个对象MarketRepairRecord 通过code
     * @param code 编码
     * @return MarketRepairRecord
     */
    public MarketRepairRecord loadByCode(java.lang.String code) {
        if(code==null){
            throw new MarketRepairRecordException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        return marketRepairRecordFeignApi.loadByCode(code);
    }


    /**
     * 删除对象MarketRepairRecord
     * @param id * @param code 编码
     * @return MarketRepairRecord
     */
    
    public void delete(java.lang.Long id,java.lang.String code) {
        if(id==null&&code==null){
            throw new MarketRepairRecordException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        marketRepairRecordFeignApi.delete(id,code);
    }



    /**
     * 查询MarketRepairRecord分页
     *
     * @param marketRepairRecord  对象
     * @param curPage 当前页
     * @param pageSize 分页条数
     * @return List<MarketRepairRecord>
     */
    public List<MarketRepairRecord> list(MarketRepairRecord marketRepairRecord, int curPage,int pageSize) {
        return marketRepairRecordFeignApi.list(marketRepairRecord, curPage,pageSize);
    }

    /**
     * 查询MarketRepairRecord分页
     *
     * @param id  * @param code  编码
     * @param curPage 当前页
     * @param pageSize 分页条数
     * @return List<MarketRepairRecord>
     */
    public List<MarketRepairRecord> list(java.lang.Long id,java.lang.String code,int curPage, int pageSize) {
        if (curPage < 0) {
           curPage = 1;
        }

        if (pageSize < 0) {
            pageSize = Page.limit;
        }

        MarketRepairRecord marketRepairRecord=new MarketRepairRecord();
        marketRepairRecord.setId(id);
        marketRepairRecord.setCode(code);

        return marketRepairRecordFeignApi.list(marketRepairRecord,curPage,pageSize);
    }


    public int count(java.lang.Long id,java.lang.String code) {
        return marketRepairRecordFeignApi.count(id,code);
    }


    public int count(MarketRepairRecord marketRepairRecord) {
        return marketRepairRecordFeignApi.count(marketRepairRecord);
    }


    /**
     * 保存
     *
     * @param marketRepairRecord 实体
     * @throws BaseException
     */
    public void save(MarketRepairRecord marketRepairRecord) {
        if(marketRepairRecord==null){ throw new MarketRepairRecordException(BaseException.BaseExceptionEnum.Ilegal_Param);}
        marketRepairRecordFeignApi.build(marketRepairRecord);
    }

    /**
     * 更新
     *
     * @param marketRepairRecord 实体
     * @throws BaseException
     */
    public void modify(MarketRepairRecord marketRepairRecord) {
        if(marketRepairRecord==null){ throw new MarketRepairRecordException(BaseException.BaseExceptionEnum.Ilegal_Param);}
        marketRepairRecordFeignApi.modify(marketRepairRecord);
    }

}
